package com.scpii.api.domain.app;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Date;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.scpii.api.common.Constants;
import com.scpii.api.common.base.FilterEntity;
import com.scpii.api.common.json.serializer.ResourceUrlSerializer;

public class AppNodes extends FilterEntity implements Serializable {
	private Long id;

	@JsonIgnore
	private String appId;

	private String name;

	@JsonIgnore
	private String parentId;

	private String moduleId;

	@JsonIgnore
	private Integer dataType;

	@JsonIgnore
	private Date createDt;

	@JsonIgnore
	private Long createBy;

	@JsonIgnore
	private Date updateDt;

	@JsonIgnore
	private Long updateBy;

	@JsonSerialize(using = ResourceUrlSerializer.class, include = JsonSerialize.Inclusion.NON_NULL)
	private String thumbImage;

	private String valueStr;

	private String interfaceUrl;

	private Integer subCount;

	private static final long serialVersionUID = 1L;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId == null ? null : appId.trim();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name == null ? null : name.trim();
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId == null ? null : parentId.trim();
	}

	public String getModuleId() {
		return moduleId;
	}

	public void setModuleId(String moduleId) {
		this.moduleId = moduleId == null ? null : moduleId.trim();
	}

	public Integer getDataType() {
		return dataType;
	}

	public void setDataType(Integer dataType) {
		this.dataType = dataType;
	}

	public Date getCreateDt() {
		return createDt;
	}

	public void setCreateDt(Date createDt) {
		this.createDt = createDt;
	}

	public Long getCreateBy() {
		return createBy;
	}

	public void setCreateBy(Long createBy) {
		this.createBy = createBy;
	}

	public Date getUpdateDt() {
		return updateDt;
	}

	public void setUpdateDt(Date updateDt) {
		this.updateDt = updateDt;
	}

	public Long getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(Long updateBy) {
		this.updateBy = updateBy;
	}

	public String getThumbImage() {
		return thumbImage;
	}

	public void setThumbImage(String thumbImage) {
		this.thumbImage = thumbImage == null ? null : thumbImage.trim();
	}

	public String getValueStr() {
		return valueStr;
	}

	public void setValueStr(String valueStr) {
		this.valueStr = valueStr == null ? null : valueStr.trim();
	}

	public String getInterfaceUrl() {
		if (Constants.TABLE_PRIKARY_KEY_START_POSITION.get("APP_NODES") == (long) dataType) {
			interfaceUrl = MessageFormat.format(
					Constants.APP_NODES_INTERFACE_URL_TEMPLATE,
					String.valueOf(id));
		}
		if (Constants.TABLE_PRIKARY_KEY_START_POSITION.get("ARTICLES") == (long) dataType) {
			interfaceUrl = MessageFormat.format(
					Constants.ARTICLES_INTERFACE_URL_TEMPLATE,
					String.valueOf(id));
		}
		if (Constants.TABLE_PRIKARY_KEY_START_POSITION.get("RESOURCES") == (long) dataType) {
			interfaceUrl = MessageFormat.format(
					Constants.RESOURCE_INTERFACE_URL_TEMPLATE,
					String.valueOf(id));
		}
		if (Constants.TABLE_PRIKARY_KEY_START_POSITION.get("ADDRESS") == (long) dataType) {
			interfaceUrl = MessageFormat.format(
					Constants.ADDRESS_INTERFACE_URL_TEMPLATE,
					String.valueOf(id));
		}
		return interfaceUrl;
	}

	public void setInterfaceUrl(String interfaceUrl) {
		this.interfaceUrl = interfaceUrl;
	}

	public Integer getSubCount() {
		return subCount;
	}

	public void setSubCount(Integer subCount) {
		this.subCount = subCount;
	}

}